import os
path = input('Please input the target to get size:')
def mksize(path):
	'''
	calculate the selected file or folder size.
	'''
	total = 0
	
	if os.path.isfile(path):
		total = os.path.getsize(path)

	else:
		for i in os.listdir(path):
			filename = os.path.join(os.path.abspath(path), i)

			if os.path.isfile(filename):
				total += os.path.getsize(filename)

			if os.path.isdir(filename):
				total += mksize(filename)

	return total


		

print('The size of the selected target is:', mksize(path)) 


'''
filename = os.path.join(os.path.abspath(path), i)
		
		if os.path.isfile(filename):
			total += os.path.getsize(filename)

		if os.path.isdir(filename):
			total += mksize(filename)
'''